# test 测试
#encoding:UTF-8
from urllib import request
import re


url = "http://sz.58.com/meirongjianshen"

user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'
headers = {'User-Agent': user_agent}
try:
    req = request.Request(url, headers=headers)
    response = request.urlopen(req)
    content = response.read().decode('utf-8')
    # print(content)
    pattern = re.compile(r' <li  class="job_item clearfix"  >', re.S)
    items = re.findall(pattern, content)
    print("************解析:",len(items))
    for item in items:
        print(item, '\n')
except request.URLError as e:
    if hasattr(e, "code"):
        print(e.code)
    if hasattr(e, "reason"):
        print(e.reason)

